layui.use(['table', 'element', 'form', 'laydate', "code"], function () {
});

$(function (){

    $("#table_body").html("");

    $.get("/flink_config/history?id=" + getCookie("flink-project-history-id"), function(req) {
        var table_html = "";
        for (let i = 0; i < req.length; i++) {
            var data = req[i];
            table_html += "<tr>  " +
                "              <td>" + data.createTime + "</td>  " +
                "              <td>" + data.userName + "</td>  " +
                "              <td>" + data.typeStr + "</td>  ";

            if (data.command.length < 1) {
                table_html += "<td></td>  ";
            } else {
                table_html += "<td>" +
                    "              <button type=\"button\" class=\"layui-btn layui-btn-xs\" onclick=\"openCommandView('" + data.id + "')\">查看指令</button>\n " +
                    "          </td>  ";
            }

            table_html += "</tr>"
        }
        $("#table_body").html(table_html);
    });

});

function openCommandView(id) {
    $.get("/flink_config/getHistoryById?id=" + id, function(req) {
        layer.open({
            area:["800px", "400px"],
            title: '命令详细',
            content: req.command
        });
    });
}